package cn.org.hentai.desktop.util;

import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;

/**
 * Created by Expect on 2018/1/25.
 */
public final class BeanUtils {
	private static BeanFactory beanFactory;

	public static void init(ApplicationContext context) {
		BeanUtils.beanFactory = context;
	}

	public static <T> T create(Class serviceClass) {
		return (T) beanFactory.getBean(serviceClass);
	}

	public static void release(Object bean) {
		try {
			// beanFactory.destroyBean(bean);
		} catch (Exception e) {
			Log.error(e);
		}
	}

	public static void main(String[] args) throws ClassNotFoundException, InstantiationException,
			IllegalAccessException, UnsupportedLookAndFeelException {
		UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
		UIManager.put("OptionPane.messageFont", new Font("黑体", Font.PLAIN, 36));
		UIManager.put("OptionPane.minimumSize", new Dimension(600, 400));
		JOptionPane.showMessageDialog(null, "即将开始共享桌面！", "远程桌面消息提醒", JOptionPane.INFORMATION_MESSAGE);
		System.exit(0);
	}
}
